<?php
namespace Admin\Controller;
use Think\Controller;
class userController extends Controller {
    public function index(){
        $this->display();
    }
    public function userlist(){
		
		$usermodel=M('user');
		$users=$usermodel->order('uid ')->select();
		$this->user=$users;
		$this->display();
	}
	public function deluser($uid){
	$usermodel=M('user');	
	if (false!==$usermodel->where("uid=$uid")->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
		
	}
    public   function uadd(){
        // $uname=$_user['uname'];
        // $upwd=$_user['upwd'];
        // $usertime=$_user['usertime'];
        // $charge=$_user['charge'];
        // $utel=$_user['utel'];
        // $uadress=$_user['uadress'];
        // $usermodel=M('user');
        // if ($usermodel->create()) {
            
        //     if (false !==$usermodel->add()) {
        //         //echo $user->getLastSql();
        //         $this->success('添加成功！', 'userlist');
        //     }
        //     else
        //     {
        //         $this->error('添加失败','userlist');
        //     }
        // }
        // }



        $users = D('user'); 
        $data['uname']=I('post.uname');
        $data['upwd']=I('post.upwd');
        $data['utel']=I('post.utel');  
        $data['uaddress']=I('post.uaddress');
        // $data['uid']=S('uid');
        dump($data);
        
         if(false!==$users->add($data)){
             $this->success('成功','userlist');
         }else{
            $this->error('失败','userlist');
         }
        }

        public   function editu(){

              $users = D('user'); 
        $uid=I('post.uid');      
        $data['uname']=I('post.uname');
        $data['upwd']=I('post.upwd');
        $data['utel']=I('post.utel');  
        $data['uaddress']=I('post.uaddress');
        dump($data);
        if(false !== $users->where("uid=$uid")->save($data)){
            $this->success('成功','userlist');
         }else{
            $this->error('失败');
         }
        }
        public function edit(){    
            $users = D('user'); 
            $uid=$_GET['uid'];
            $res= $users->where("uid=$uid")->find();
            $this->user=$res;
         
        $this->display();
        }
}